/**
 * Created by zengxm on 12/21/2016.
 */
const fs=require('fs')

const jdkVersion='java version "1.8.0_92"\
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)\
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)'

//抽取版本号
console.log(jdkVersion.indexOf("1.8"))
console.log(jdkVersion.indexOf("1.9"))

var v=/"([^"]*)"/.exec(jdkVersion) || []
if(v!=null){
    console.log("version="+v[1])

    console.log("version > 1.8+ = ", v[1]>"1.8")
}
if(v!=null && v[1]>="1.8")
    console.log("version check ok")

//读取文件大小
const stat=fs.statSync("./tmp-test.tar.gz")
console.log(stat)

console.log("显示进度条");

var ProgressBar = require('progress');

var bar = new ProgressBar(':bar', { total: 50 });
var timer = setInterval(function () {
    bar.tick();
    if (bar.complete) {
        console.log('\ncomplete\n');
        clearInterval(timer);
    }
}, 100);